<template>
  <div class="PowerPlantbox">
    <div class="title">
      <div class="left">
        <div class="length"></div>
        <div class="text">虚拟电厂检测--{{ treevalue.name }}</div>
      </div>
      <div>
        <span class="time">数据时间：</span>
        <el-date-picker
          v-model="date"
          type="date"
          size="small"
          value-format="yyyy-MM-dd"
          @change="getallmethod(treevalue)"
          placeholder="选择日期">
        </el-date-picker>
      </div>
    </div>
    <div class="threebox">
      <div class="little">
        <div><img src="@/assets/ElectricalDistribution/SX-hrss/user.png" alt=""> </div>
        <div>
          <div class="text">用户总数 (户)</div>
          <div class="number">{{ entityvalue.userNum }}</div>
        </div>
      </div>
      <div class="little model">
        <div><img src="@/assets/ElectricalDistribution/SX-hrss/rong.png" alt=""> </div>
        <div>
          <div class="text">机组设备数 (个)</div>
          <div class="number">{{ entityvalue.deviceNum }}</div>
        </div>
      </div>
      <div class="little">
        <div><img src="@/assets/ElectricalDistribution/SX-hrss/device.png" alt=""> </div>
        <div>
          <div class="text">机组额定总容量 (kWh)</div>
          <div class="number">{{ entityvalue.ratedCapacity }}</div>
        </div>
      </div>
    </div>
    <div class="echartbox">
      <div class="tit">
        <div class="left">
          <div class="length"></div>
          <div class="text">负荷监测</div>
        </div>
      </div>
      <div class="echart" ref="fuherefs"></div>
    </div>
    <div class="title real">
      <div class="left">
        <div class="length"></div>
        <div class="text">实时监测</div>
      </div>
    </div>
    <div class="realtime">
      <div class="realbox parang">
        <div class="left">
          <div class="text">总出力</div>
          <div class="number">{{ entityvalue.totalOutput }}</div>
        </div>
        <div class="right">
          <img src="@/assets/ElectricalDistribution/SX-hrss/image copy 2.png" alt="">
        </div>
      </div>
      <div class="realbox parang">
        <div class="left">
          <div class="text">负荷调控机组出力(kW)</div>
          <div class="number">{{ entityvalue.loadControlOutput }}</div>
          <div class="text">发电量(kWh)</div>
          <div class="number">{{ entityvalue.loadControlGeneration }}</div>
        </div>
        <div class="right">
          <img src="@/assets/ElectricalDistribution/SX-hrss/image copy 5.png" alt="">
        </div>
      </div>
      <div class="realbox parang">
        <div class="left">
          <div class="text">分布式发电机组出力(kW)</div>
          <div class="number">{{ entityvalue.distributedOutput }}</div>
          <div class="text">发电量(kWh)</div>
          <div class="number">{{ entityvalue.distributedGeneration }}</div>
        </div>
        <div class="right">
          <img src="@/assets/ElectricalDistribution/SX-hrss/image copy 6.png" alt="">
        </div>
      </div>
      <div class="realbox">
        <div class="left">
          <div class="text">双向调节机组出力(kW)</div>
          <div class="number">{{ entityvalue.bidirectionalControlOutput }}</div>
          <div class="chong">
            <div class="dis text">充电量</div>
            <div class="dis text">剩余电量</div>
          </div>
          <div class="chong">
            <div class="dis number">{{ entityvalue.bidirectionalControlCharge }}</div>
            <div class="dis number">{{ entityvalue.bidirectionalControlDisCharge }}</div>
          </div>
        </div>
        <div class="right">
          <img src="@/assets/ElectricalDistribution/SX-hrss/image copy 7.png" alt="">
        </div>
      </div>
    </div>
    <div class="echartbox">
      <div class="tit">
        <div class="left">
          <div class="length"></div>
          <div class="text">出力监测</div>
        </div>
      </div>
      <div class="echart" ref="chulirefs"></div>
    </div>
    <div class="echartbox">
      <div class="tit">
        <div class="left">
          <div class="length"></div>
          <div class="text">电量监测</div>
        </div>
      </div>
      <div class="echart" ref="dianrefs"></div>
    </div>
  </div>
</template>
<script>
import {plantinfoapi,plantdianapi,plantloadapi,plantchuliapi} from '@/api/ElectricalDistribution/ResourceMonitoring'
import { GetdataZoomEchart } from '../components/dataZoomech'
import dayjs from 'dayjs';
export default {
  name: 'CallPoliceIndex',
  props: {
    treevalue: {
      type: Object,
      default:()=>{}
    }
  },
  data() {
    return {
      date: '',
      entityvalue: {},
      colorlist:['#efc47b','#58dbc5','#1a7ef5','#b86df8']
    };
  },

  mounted() {
  },

  methods: {
    async getallmethod(val) {
      const { data: { entity } } = await plantinfoapi({ devId: val.id, day: this.date })
      this.entityvalue = entity
      const { data: { list } } = await plantdianapi({ devId: val.id, day: this.date })
      const { data: { entity:loadlist } } = await plantloadapi({ devId: val.id, day: this.date })
      const { data: { list:chulilist } } = await plantchuliapi({ devId: val.id, day: this.date })
      GetdataZoomEchart(this.$refs.dianrefs,list,this.colorlist,true)
      GetdataZoomEchart(this.$refs.fuherefs,[loadlist],this.colorlist,true)
      GetdataZoomEchart(this.$refs.chulirefs,chulilist,this.colorlist,true)
    }
  },
  watch: {
    treevalue: {
      immediate:true,
      handler(newValue, oldValue) {
        this.date=dayjs().format('YYYY-MM-DD')
        this.getallmethod(newValue)
      },
      deep: true // 深度监听对象内部属性的变化
    }
  }
};
</script>
<style lang="scss" scoped>
.PowerPlantbox{
  .title{
    display:flex;
    justify-content:space-between;
    height:60px;
    align-items:center;
    background-color:#fff;
    padding:0 20px;
    .left{
      display:flex;
      font-weight: bold;
      .length{
        width:3px;
        height:20px;
        background-color:#3b8eea;
        margin-right:10px;
      }
    }
    .time{
      font-size:14px;
      color:#606266;
    }
  }
  .threebox{
    height: 100px;
    display: flex;
    margin-top: 10px;
    .little{
      width: calc(33.3% - 6.7px);
      background-color: #fff;
      padding: 20px;
      display: flex;
      align-items: center;
      img{
        width: 60px;
        height: 60px;
        margin-right: 50px;
      }
      .text{
        font-size: 14px;
        color:#606266;
      }
      .number{
        color: #000;
        font-size: 18px;
      }
    }
    .model{
      margin: 0 10px;
    }
  }
  .echartbox{
    height: 300px;
    padding: 20px;
    background-color: #fff;
    margin-top: 10px;
    .tit{
      display:flex;
      // margin-bottom: 10px;
      justify-content:space-between;
      .left{
        display:flex;
        font-weight: bold;
        .length{
          width:3px;
          height:20px;
          background-color:#3b8eea;
          margin-right:10px;
        }
      }
    }
    .echart{
      height: 90%;
    }
  }
  .real{
    margin-top: 10px;
  }
  .realtime{
    height: 150px;
    margin: 10px 0;
    display: flex;
    .realbox{
      width: calc(25% - 7.5px);
      background-color: #fff;
      padding: 20px;
      display: flex;
      .left{
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;
        width: 60%;
        .text{
          font-size: 14px;
          color:#606266;
        }
        .number{
          font-size: 18px;
          color: #000;
        }
        .chong{
          display: flex;
          .dis{
            width: 50%;
          }
        }
      }
      .right{
        width: 40%;
        display: flex;
        align-items: center;
      }
    }
    .parang{
      margin-right: 10px;
    }
  }
}
</style>